package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.FinanceRequest;
import one.stand.request.SeeRecordRequest;
import one.stand.request.TokenRequest;
import one.stand.response.CrmCustomerAnalysisRespnse;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author: ZRH
 * @CreateDate: 2019/4/17 9:45
 */
@RestController
@RequestMapping("crmPc/index")
@Api(tags="crm-PC首页")
public class IndexController extends BaseController{

    @ApiOperation(value = "CRM-PC端首页统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "1个人数据，2企业数据", required = true, paramType = "Integer"),
    })
    @PostMapping("getPcCount")
    @ApiController(isLogin = true,company=true, card = true,paramClass =SeeRecordRequest.class )
    public ResultModel<Map<String, Object>> getPcCount(@RequestAttribute SeeRecordRequest request) {
        return crmFegin.getPcCount(request);
    }

    @ApiOperation(value = "CRM-PC端首页转化率漏斗")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dayNum", value = "天数，不传值就默认30天", paramType = "Integer"),
            @ApiImplicitParam(name = "type", value = "1个人数据2企业数据", required = true,paramType = "Integer"),
    })
    @PostMapping("getChangeCount")
    @ApiController(isLogin = true,company=true, card = true,paramClass =SeeRecordRequest.class)
    public ResultModel<Map<String, Object>> getChangeCount(@RequestAttribute SeeRecordRequest request) {
        return crmFegin.getChangeCount(request);
    }

    @ApiOperation("圆饼图")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "客户ID（用户客户分析）", paramType = "Integer"),
            @ApiImplicitParam(name = "dayNum", value = "天数", paramType = "Integer"),
            @ApiImplicitParam(name = "type", value = "1个人数据2企业数据", required = true,paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true, card = true,paramClass =SeeRecordRequest.class)
    @PostMapping("countCustomerAnalysis")
    public ResultModel<List<CrmCustomerAnalysisRespnse>> countCustomerAnalysis(@RequestAttribute SeeRecordRequest request) {
        
        return crmFegin.countCustomerAnalysis(request);
    }

    @PostMapping("sevenData")
    @ApiOperation(value = "近7日成交额")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "1个人数据2企业数据", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true, card = true,paramClass =FinanceRequest.class)
    public ResultModel sevenData(@RequestAttribute FinanceRequest request) {
        return crmFegin.sevenData(request);
    }
}
